package httpserver

import (
	"gitee.com/fierce_wolf/go-fox-edge-common/commUtil/AjaxResult"
	"github.com/gin-gonic/gin"
	"net/http"
)

type IRespond interface {
	Respond(context *gin.Context, data interface{}, err error)
}

type DefaultRespond struct {
}

func (e *DefaultRespond) Respond(context *gin.Context, data interface{}, err error) {
	if err != nil {
		context.JSON(http.StatusOK, AjaxResult.Error(err.Error(), nil))
	} else {
		context.JSON(http.StatusOK, AjaxResult.Success("操作成功", data))
	}
}
